#coding:utf8
import sys
import cherrypy
import os
import logging
import datetime

from head import head
from menu import *
import login
from end import end

import sbxx
import sbdak
import sbwh
import sbxz
import sbbgjl
import sbbgxz
import sbbgxx
import zzjg
import sblx

from utf8code import *

class Index:
    login = login.Login()
    sbxx = sbxx.JSJSB()
    sbbgxz = sbbgxz.BGXZ()
    sbxz = sbxz.SBXZ()
    sbwh = sbwh.SBWH()
    sbdak = sbdak.SBDAK()
    sbbgjl = sbbgjl.SBBGJL()
    sbbgxx = sbbgxx.BGXX()
    zzjg = zzjg.ZZJG()
    sblx = sblx.SBLX()
    
    #启用session
    _cp_config = {'tools.sessions.on': True}
    
    @cherrypy.expose
    def index(self):
        return utf8code(head() % '聚隆设备管理【易用版】' + login._js + menu() + login.login() + end())

if __name__ == '__main__':
    reload(sys)
    sys.setdefaultencoding('utf8')
    
    logger = logging.getLogger()
    logFileName = datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d')+'_Console.log'
    logfile = logging.FileHandler(os.path.join(os.getcwd(),'log',logFileName))
    logger.addHandler(logfile)

    _curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
    conf = os.path.join(os.path.dirname(__file__), 'conf', 'tutorial.conf')
    logger.info(cherrypy.quickstart(Index(), config = conf))